package net.siufung.simple.config;

import lombok.AllArgsConstructor;
import net.siufung.boot.knife4j.entity.DocketApiDto;
import net.siufung.boot.knife4j.properties.Knife4jProperties;
import net.siufung.boot.knife4j.support.SpringfoxSupport;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * @author 陈建峰
 * @since 2022/4/4 6:25 下午
 */
@Configuration
@AllArgsConstructor
public class Knife4jConfig {

    private final Knife4jProperties knife4jProperties;

    /**
     * 配置Knife4j扫描拦截
     * @param apiInfo api配置文件
     * @return Docket
     */
    @Bean(name = "security")
    public Docket createSecurityApi(ApiInfo apiInfo){
        DocketApiDto docketApiDto = new DocketApiDto();
        docketApiDto.setGroupName("会话管理");
        docketApiDto.setBasePackage("net.siufung.simple.security");
        return SpringfoxSupport.createRestApi(apiInfo, knife4jProperties, docketApiDto);
    }

    /**
     * 配置Knife4j扫描拦截
     * @param apiInfo api配置文件
     * @return Docket
     */
    @Bean(name = "demo")
    public Docket createDemoApi(ApiInfo apiInfo){
        DocketApiDto docketApiDto = new DocketApiDto();
        docketApiDto.setGroupName("DEMO演示");
        docketApiDto.setBasePackage("net.siufung.simple.demo");
        return SpringfoxSupport.createRestApi(apiInfo, knife4jProperties, docketApiDto);
    }

    /**
     * 配置Knife4j扫描拦截
     * @param apiInfo api配置文件
     * @return Docket
     */
    @Bean(name = "base")
    public Docket createBaseApi(ApiInfo apiInfo){
        DocketApiDto docketApiDto = new DocketApiDto();
        docketApiDto.setGroupName("基础数据");
        docketApiDto.setBasePackage("net.siufung.market.base");
        return SpringfoxSupport.createRestApi(apiInfo, knife4jProperties, docketApiDto);
    }

    /**
     * 配置Knife4j扫描拦截
     * @param apiInfo api配置文件
     * @return Docket
     */
    @Bean(name = "mes")
    public Docket createMesApi(ApiInfo apiInfo){
        DocketApiDto docketApiDto = new DocketApiDto();
        docketApiDto.setGroupName("智能制造");
        docketApiDto.setBasePackage("net.siufung.market.mes");
        return SpringfoxSupport.createRestApi(apiInfo, knife4jProperties, docketApiDto);
    }

}
